#include "StdAfx.h"
#include "LinkED_Utility.h"


CUtility::CUtility(void)
{
}


CUtility::~CUtility(void)
{
}

std::string CUtility::GetLocalIP()
{
    char name[255] = {0};
    PHOSTENT hostinfo;

    if(gethostname(name, sizeof(name)) == 0)
    {
        if((hostinfo = gethostbyname(name)) != NULL)
        {
            return inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list);
        }
    }

    return "";
}

bool CUtility::InitialWindowsSock()
{
    WSADATA wsaData;

    if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) 
    {
        return false;
    }

    return true;
}

std::string CUtility::GetPCName()
{
    char name[255] = {0};

    if(gethostname(name, sizeof(name)) == 0)
    {
        return name;
    }

    return "";
}
